class Solution {
public:
    vector<int> twoSum(vector<int>& price, int target) {
        int left = 0, right = price.size() - 1;
        while(left < right)
        {
            int sum = price[left] + price[right];
            if(sum < target)
            {
                ++left;
            }
            else if(sum > target)
            {
                --right;
            }
            else
            {
                return {price[left], price[right]}; // 直接构造成vector返回
            }
        }
        return {-1,-1}; // 预防编译器的检查
    }
};